<?php 
error_reporting(E_ALL);
session_start();
require_once('constants_shop.php');
require_once('functions.php');
include('classes/userClass.php');



#conect to shop database	
$shopObj = new mysqlClass();

if(isset($_POST['field_update'])){
	$params[$_POST['field_update']]=$_POST['value'];
	$params['id']=$_POST['product']; 
	$shopObj->update('products',$params);

}
if(isset($_POST['delete_product'])){
	$params=array();
	$params['product_id'] =$_POST['delete_product'];
	$shopObj->delete('products_details',$params);
	$shopObj->delete('products_comments',$params);
	$shopObj->delete('products_questions',$params);
	$shopObj->delete('product_articles',$params);
	$shopObj->delete('products_ratings',$params);
	$shopObj->delete('products_categories',$params);
	$shopObj->delete('stocks',$params);
	
	$params=array('id'=>$_POST['delete_product']);
	$shopObj->delete('products',$params);

	
	
	
	
}
if(isset($_POST['delete_selected'])){
	$products = explode(',',$_POST['delete_selected']);

	foreach($products as $value){
		$params=array();
		$params['product_id'] =$value;
		$shopObj->delete('products_details',$params);
		$shopObj->delete('products_comments',$params);
		$shopObj->delete('products_questions',$params);
		$shopObj->delete('product_articles',$params);
		$shopObj->delete('product_ratings',$params);
		$shopObj->delete('products_categories',$params);
		
		$params=array('id'=>$value);
		$shopObj->delete('products',$params);
		$params= array($value);
		$shopObj->execute_query("DELETE  FROM  product_properties WHERE product_id=? ",$params);
	}
}
?>